﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
using Tunynet;
using Tunynet.Caching;
using Tunynet.Common;
using Tunynet.Repositories;
using Tunynet.Utilities;
using Spacebuilder.Common;

namespace Spacebuilder.Common
{
    /// <summary>
    /// 短信模版实现
    /// </summary>
    public class SmsTemplatesRepository : Repository<SmsTemplates>, ISmsTemplatesRepository
    {
        /// <summary>
        /// 获取短信模版
        /// </summary>
        /// <param name="Id">ID</param>
        /// <returns></returns>
        public IEnumerable<SmsTemplates> GetSmsTemplates(int id)
        {
            Sql sql = Sql.Builder;

            sql.Select("tn_SmsTemplates.*")
               .From("tn_SmsTemplates")
               .Where("tn_SmsTemplates.id = @0", id)
               .OrderBy("tn_SmsTemplates.id desc");

            return GetPagingEntities(base.PrimaryMaxRecords, 1, sql);


        }
    }
}
